package com.tst.app.conf;

import org.slf4j.LoggerFactory;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

/**
 * 移动推送配置
 * Created by John on 2017/12/9.
 */
@Configuration
public class MobilePushConfiguration implements EnvironmentAware {
    private static final org.slf4j.Logger logger = LoggerFactory.getLogger(MobilePushConfiguration.class);

    public static final String ACCESSKEY_ID = "sts.accessKeyId";
    public static final String ACCESSKEY_SECRET = "sts.accessKeySecret";
    public static final String ROLE_ARN = "sts.roleArn";
    public static final String ENV = "sts.env";


    private Environment environment;

    @Override
    public void setEnvironment(Environment environment) {
        this.environment = environment;
        this.initConfig();
    }


    public void initConfig() {
        StsConfig.getInstance().setAccessKeyId(environment.getProperty(ACCESSKEY_ID));
        StsConfig.getInstance().setAccessKeySecret(environment.getProperty(ACCESSKEY_SECRET));
        StsConfig.getInstance().setRoleArn(environment.getProperty(ROLE_ARN));
        StsConfig.getInstance().setEnv(environment.getProperty(ENV));

        logger.info("移动推送配置为" + StsConfig.getInstance().toString());
    }
}
